﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:cal="http://www.caliburnproject.org"
             xmlns:ctrl="clr-namespace:MediaOwl.Common.ControlTemplates;assembly=MediaOwl.Common"
             x:Class="MediaOwl.LastFm.Views.MusicTagSingleView"
             mc:Ignorable="d"
             d:DesignHeight="431"
             d:DesignWidth="514">
    <UserControl.Resources>
        <DataTemplate x:Key="CompactItemTemplate">
            <Grid Width="90">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Rectangle Fill="{StaticResource TreeViewItemSelectionBorder}"
                           Stroke="{StaticResource ColorAccentBrush}"
                           Width="50"
                           Height="50"
                           Margin="10,0" />
                <TextBlock TextWrapping="Wrap"
                           Text="No Image"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Center"
                           Foreground="{StaticResource ControlForeground}"
                           Width="50"
                           TextAlignment="Center" />
                <Image Source="{Binding PictureSmall}"
                       Width="50"
                       Height="50"
                       Stretch="UniformToFill"
                       Margin="10,0" />
                <TextBlock Margin="0,5"
                           TextWrapping="Wrap"
                           d:LayoutOverrides="Width"
                           Text="{Binding Name}"
                           Grid.Row="1"
                           Foreground="{StaticResource ControlForeground}"
                           HorizontalAlignment="Center"
                           TextAlignment="Center" />
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="ArtistChartItemTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Rectangle Fill="{StaticResource TreeViewItemSelectionBorder}"
                           Stroke="{StaticResource ColorAccentBrush}"
                           Width="50"
                           Height="50" />
                <TextBlock TextWrapping="Wrap"
                           Text="No Image"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Center"
                           Foreground="{StaticResource ControlForeground}"
                           RenderTransformOrigin="0.5,0.5">
				<TextBlock.RenderTransform>
					<CompositeTransform Rotation="-45" />
				</TextBlock.RenderTransform>
                </TextBlock>
                <Image Source="{Binding Picture}"
                       Width="50"
                       Height="50"
                       Stretch="UniformToFill" />
                <Rectangle Fill="{StaticResource ControlBackgroundPressedOrange}"
                           Grid.Column="1"
                           Margin="5"
                           Width="{Binding Points}"
                           Opacity="0.75"
                           RadiusX="3"
                           RadiusY="3"
                           HorizontalAlignment="Left" />
                <TextBlock Margin="10,5"
                           TextWrapping="Wrap"
                           d:LayoutOverrides="Width"
                           Text="{Binding Name}"
                           Grid.Row="1"
                           Foreground="{StaticResource ControlForeground}"
                           FontWeight="Bold"
                           Grid.Column="1"
                           VerticalAlignment="Center"
                           Style="{StaticResource Heading5}" />
            </Grid>
        </DataTemplate>
    </UserControl.Resources>
    <ctrl:WorkitemControl BusyContext="{Binding CurrentBusyViewModel}"
                          DialogContext="{Binding ActiveDialog}">
        <toolkit:DockPanel Margin="5">
            <StackPanel Orientation="Horizontal"
                        d:LayoutOverrides="Height"
                        toolkit:DockPanel.Dock="Top"
                        Margin="0,0,0,15">
                <TextBlock x:Name="DisplayName"
                           TextWrapping="Wrap"
                           Style="{StaticResource Heading2}" />
            </StackPanel>
            <Border BorderBrush="{StaticResource ControlBorderBrush}"
                    BorderThickness="1"
                    toolkit:DockPanel.Dock="Bottom"
                    Margin="10,15,10,10"
                    CornerRadius="3"
                    Background="{StaticResource DarkInnerShadowDarkBrush}"
                    Padding="5">
                <Button x:Name="TryClose"
                        Content="Close"
                        HorizontalAlignment="Right" />
            </Border>
            <sdk:TabControl toolkit:DockPanel.Dock="Top"
                            Margin="10,0">
                <sdk:TabItem Header="Weekly Artist Charts">
                    <ListBox x:Name="WeeklyArtistChart"
                             ItemTemplate="{StaticResource ArtistChartItemTemplate}"
                             ScrollViewer.VerticalScrollBarVisibility="Auto"
                             Margin="-5"
                             Style="{StaticResource InvisibleListBoxStyle}"
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectionChanged">
                                <cal:ActionMessage MethodName="OpenArtist">
                                    <cal:Parameter Value="{Binding SelectedItem, ElementName=WeeklyArtistChart}" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </ListBox>
                </sdk:TabItem>
                <sdk:TabItem Header="Artists">
                    <ListBox x:Name="TopArtists"
                             ItemTemplate="{StaticResource CompactItemTemplate}"
                             ItemsPanel="{StaticResource WrappingItemsPanelTemplate}"
                             ScrollViewer.VerticalScrollBarVisibility="Auto"
                             Margin="-5"
                             Style="{StaticResource InvisibleListBoxStyle}"
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectionChanged">
                                <cal:ActionMessage MethodName="OpenArtist">
                                    <cal:Parameter Value="{Binding SelectedItem, ElementName=TopArtists}" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </ListBox>
                </sdk:TabItem>
                <sdk:TabItem Header="Albums">
                    <ListBox x:Name="TopAlbums"
                             ItemTemplate="{StaticResource CompactItemTemplate}"
                             ItemsPanel="{StaticResource WrappingItemsPanelTemplate}"
                             ScrollViewer.VerticalScrollBarVisibility="Auto"
                             Margin="-5"
                             Style="{StaticResource InvisibleListBoxStyle}"
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectionChanged">
                                <cal:ActionMessage MethodName="OpenAlbum">
                                    <cal:Parameter Value="{Binding SelectedItem, ElementName=TopAlbums}" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </ListBox>
                </sdk:TabItem>
                <sdk:TabItem Header="Tracks">
                    <ListBox x:Name="TopTracks"
                             ItemTemplate="{StaticResource CompactItemTemplate}"
                             ItemsPanel="{StaticResource WrappingItemsPanelTemplate}"
                             Margin="-5"
                             Style="{StaticResource InvisibleListBoxStyle}"
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectionChanged">
                                <cal:ActionMessage MethodName="OpenTrack">
                                    <cal:Parameter Value="{Binding SelectedItem, ElementName=TopTracks}" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </ListBox>
                </sdk:TabItem>
            </sdk:TabControl>
        </toolkit:DockPanel>
    </ctrl:WorkitemControl>
</UserControl>
